package com.yonyougov.devops.cruxcisupport.envserver;

import com.yonyougov.devops.cruxcisupport.envserver.vo.EnvServerPageLikeReqVoParams;
import com.yonyougov.devops.cruxcisupport.envserver.vo.EnvServerPageLikeRespVoParams;
import com.yonyougov.devops.fwc.core.dao.impl.BaseDaoImpl;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import java.math.BigInteger;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * t_env_server数据层实现
 */
@Repository
public class EnvServerDaoImpl extends BaseDaoImpl<EnvServerEntity, BigInteger> implements EnvServerDao {

    private final SqlSessionTemplate sqlSessionTemplate;

    public EnvServerDaoImpl(SqlSessionTemplate sqlSessionTemplate) {
        this.sqlSessionTemplate = sqlSessionTemplate;
    }

    //<!--用户自定义代码开始-->
    @Override
    public void batchDelete(List<EnvServerEntity> list) {
        String statement = EnvServerEntity.class.getName() + "Mapper.batchDelete";
        Map<String, Object> map = new HashMap<>();
        map.put("list", list);
        sqlSessionTemplate.delete(statement, list);
    }

    @Override
    public int countByLikeEnvServer(EnvServerPageLikeReqVoParams pageParams) {
        String statement = EnvServerEntity.class.getName() + "Mapper.countByLikeEnvServer";
        return sqlSessionTemplate.selectOne(statement, pageParams);
    }

    @Override
    public List<EnvServerPageLikeRespVoParams> findAllByParamsLike(EnvServerPageLikeReqVoParams pageParams) {
        String statement = EnvServerEntity.class.getName() + "Mapper.findAllByParamsLike";
        return sqlSessionTemplate.selectList(statement, pageParams);
    }

    //<!--用户自定义代码结束-->
}
